"""
全局配置文件
"""
import os
import calendar
import time

utc_time = calendar.timegm(time.gmtime())

"""获取执行时间"""
run_time = str(time.strftime("%Y-%m-%d_%H_%M", time.localtime()))

"""获取项目根目录"""

# 获取文件目录
curPath = os.path.abspath(os.path.dirname(__file__))
# 获取项目根路径，内容为当前项目的名字
# 修复：获取包含子目录的完整项目路径
if 'HOKInterfaceAutoTest' in curPath:
    # 如果路径中包含多个HOKInterfaceAutoTest，取最后一个
    last_index = curPath.rfind('HOKInterfaceAutoTest')
    root_path = curPath[:last_index + len('HOKInterfaceAutoTest')]
else:
    # 如果没有找到，使用当前目录的父目录
    root_path = os.path.dirname(curPath)

"""测试环境相关配置"""
# 当前代码的测试环境，修改此处则可实现环境切换
NOW_ENV = "BETA"

"""B端接口不同测试环境对应的域名"""
URL_ENV_TEST = "https://test.webhok.hokkj.cn"
URL_ENV_BETA = "https://beta.webhok.hokkj.cn"
URL_ENV_SOA = "https://soa.webhok.hokkj.cn"

"""H5端接口不同测试环境对应的域名"""
C_URL_ENV_TEST = "https://beta.test.hokkj.cn"
C_URL_ENV_BETA = "https://beta.h5.hokkj.cn"
C_URL_ENV_SOA = "https://h5.hokkj.cn"

"""不同环境对应的数据库链接"""
TEST_DB_CONNECT = ('39.105.129.58', 3306, "root", "LrWpZb6YSufP2aUsV")
PRE_DB_CONNECT = ('betahok.rwlb.rds.aliyuncs.com', 3306, "pdk3s5_z88", "Ykdjx#FVVVWHNt3%u")
PROD_DB_CONNECT = ('rm-2ze9v5v08bw32wbb06o.mysql.rds.aliyuncs.com', 3306, "msgview2024fcs", "eaCa#!c4e10msg")

"""不同环境对应的PC端管理员账号密码"""
Test_user_info = {'account': '15773899933', 'password': '15773899933aa'}
Beta_user_info = {'account': '15773899933', 'password': '123456qq'}
Soa_user_info = {'account': '18588493298', 'password': 'Hk123456test'}

"""测试报告模块配置"""
# JSON报告存放的地址
# os.mkdir(os.path.join(root_path, "output"))
JSON_REPORT = os.path.join(root_path, "output", "json_report")
# os.mkdir(JSON_REPORT)

# HTML报告存放的地址
HTML_REPORT = os.path.join(root_path, "output", "html_report")

"""变量存储文件配置"""
# 响应中提取的数据存储路径
extract_path = os.path.join(os.path.join(root_path, 'config'), "extract.yaml")

"""日志模块配置"""
# 日志文件默认的存储地址
log_path = os.path.join(root_path, "logs")
# 日志分隔符
log_separator = "= " * 20
# 日志文件最大文件数量
MAX_LOG_FILE_NUM = 30
# 当前执行的日志存储路径
Current_log_path = os.path.join(root_path, "current_log.log")

"""环境变量存储位置"""
ENV_VARIABLE_PATH = os.path.join(os.path.join(root_path, "config"), 'GlobalEnvVariable.yaml')

"""发送飞书的url"""
FeiShuMsgUrl = {"test": 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=da4e6670-4845-4a59-a745-98a455e8ef6f',
                'external': "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=53095106-bffb-4784-94fb-47b966144d88"}

"""飞书消息存储的文件地址"""
FeiShuMsgFile = os.path.join(os.path.join(root_path, 'FeiShu'), "feishu_msg.yaml")

"""服务器测试报告链接"""
ReportUrl = 'https://apitest.hokkj.cn/output/html_report/?t=%d' % utc_time

"""超过时间（11点）不需要执行的用例.需要加的话，直接在字符串后面加，格式为： and not 用例名"""
exclude_cases = "not test_find_teacher_kuaishou and not test_find_teacher_xiaohongshu"

"""寻找师资资源释放接口调用时间"""
release_hour = 6

"""请求参数(环境变量)"""
test_request_parameters = {"kuaishou_key": "c3b6a6a563290dc4a394eed21631e352ff26d2aa76240471a7caf31d",
                           "xiaohongshu_key": "c3b6a6a563290dc4a394eed21631e352ff26d2aa76240471a7caf31d",
                           "website": "www.woshipm.com/",
                           "article_search_key": "c3b6a6a563290dc4a394eed21631e352ff26d2aa76240471a7caf31d",
                           "accountName": "aa",
                           "run_time": 5000,
                           "admin_account": 18588493298,
                           "organization_id": 1000}
beta_request_parameters = {"kuaishou_key": "c3b6a6a563290dc4a394eed21631e352ff26d2aa76240471a7caf31d",
                           "xiaohongshu_key": "c3b6a6a563290dc4a394eed21631e352ff26d2aa76240471a7caf31d",
                           "website": "www.woshipm.com/",
                           "article_search_key": "c3b6a6a563290dc4a394eed21631e352ff26d2aa76240471a7caf31d",
                           "accountName": "aa",
                           "run_time": 5000,
                           "admin_account": 18588493298,
                           "organization_id": 1000,
                           "domainUrl": "https://quanyu4.hokkj.cc",
                           "copy_live_room_id": 1907642984729329664}
soa_request_parameters = {"kuaishou_key": "c3b6a6a563290dc4a394eed21631e352ff26d2aa76240471a7caf31d",
                          "xiaohongshu_key": "c3b6a6a563290dc4a394eed21631e352ff26d2aa76240471a7caf31d",
                          "website": "www.woshipm.com/",
                          "article_search_key": "c3b6a6a563290dc4a394eed21631e352ff26d2aa76240471a7caf31d",
                          "accountName": "新零售商业评论",
                          "run_time": 5000,
                          "admin_account": 18588493298,
                          "app_orderRevenue_itemIds": ['a60f8893edd74aa1a5a88cd549666f9d'],
                          "app_orderRevenue_teacherIds": ["7c030d3119f84ea39cf8e3be758f7d2f"],
                          "app_employeeSecondDeptId": 100,
                          "organization_id": 1007,
                          "domainUrl": "https://quanyu4.hokkj.cc",
                          "copy_live_room_id": 1901466353096949760}
